<!DOCTYPE html>
<html lang="en"> <!-- See http://www.w3schools.com/tags/ref_language_codes.asp -->
<head>
    <meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
    <title>XX-Net</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- CSS -->
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="/css/bootstrap-responsive.css">
    <link rel="stylesheet" type="text/css" href="/css/flat-ui.css">
    <link rel="stylesheet" type="text/css" href="/css/ladda-themeless.min.css">
    <link rel="stylesheet" type="text/css" href="/css/style.css?ver=%s">
    <!-- JavaScript -->
    <script type="text/javascript" src="/js/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/flat-ui.js"></script>
    <script type="text/javascript" src="/js/jquery.timer.js"></script>
    <script type="text/javascript" src="/js/spin.min.js"></script>
    <script type="text/javascript" src="/js/ladda.min.js"></script>
    <script type="text/javascript" src="/js/site.js?ver=%s"></script>
    <!--[if lte IE 9]>
        <script type="text/javascript" src="/js/jquery.placeholder.min.js"></script>
        <script type="text/javascript" src="/js/jquery.xdomainrequest.min.js"></script>
    <![endif]-->
</head>
<script type="text/javascript">
    var documentReadyToRun = new Array();
</script>
<body>
<div id="header" class="navbar navbar-inverse navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container">
            <div class="row-fluid">
                <div id="logo" class="span8">
                    <a href="/" title="XX-Net">
                        <img src="/img/logo.png" alt="Logo">
                        XX-Net
                        <span id="version_on_logo" class=""></span>
                    </a>
                    <a id="remote-connection-identifier" style="display: none;" href="/?module=launcher&menu=config">{{ _( "(Remote Web Control Enabled)" ) }}</a>
                </div> <!-- #logo -->
                <div class="span4 text-right">
                    <ul class="inline">
                        <li>
                            <a id="resize-window-trigger" href="javascript:void(0);" title='{{ _( "Adaptive width" ) }}'>
                                <img src="/img/fixed-width.png" alt="resize-window">
                            </a>
                        </li>
                        <li>
                            <a id="quit-trigger" href="javascript:void(0);" title='{{ _( "Exit the program" ) }}'>
                                <img src="/img/quit.png" alt="quit">
                            </a>
                        </li>
                    </ul>
                </div> <!-- .span4 -->
            </div> <!-- .row-fluid -->
        </div> <!-- .container -->
    </div> <!-- .navbar-inner -->
</div> <!-- #header -->
<div id="content">
    <div class="container">
        <div id="welcome" class="hero-unit hide" style="padding-left: 70px;">
            <button type="button" class="close" onclick="welcomeClose();" aria-hidden="true">&times;</button>
            <h1 id="welcome-title">{{ _( "Hello!" ) }}</h1>
            <p id="welcome-message">{{ _( "You seem to be on your first visit." ) }}</p>
            <a id="btn-learnmore" class="btn btn-primary btn-large">{{ _( "Learn more" ) }}</a>
        </div>
        <div class="row-fluid">
            <div id="sidebar" class="span3">
                <div id="notice" class="well">
                    <label for="notice-content" class="fluid-down-control">
                        <i class="icon icon-chevron-right"></i> <b>{{ _( "Notice" ) }} ({{ _( "click to view" ) }})</b>
                    </label>
                    <ul id="notice-content" style="display:none; overflow:auto; width:auto; height:auto; max-height:200px; list-style-type:circle"></ul>
                    <!--<svg height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>-->
                    <br/>
                </div> <!-- #notice -->
                <div class="sidebar-nav well">
                    <ul class="nav nav-list">%s</ul>
                </div> <!-- .sidebar-nav -->
            </div> <!-- #sidebar -->
            <div class="span9">
                <div id="update-notify" class="alert fade in hide">
                    <span id="update-notify-close">×</span>
                    <span id="update-now" class="update-notify-action">{{ _( "Update now" ) }}</span>
                    <span id="update-next" class="update-notify-action">{{ _( "Remind me later" ) }}</span>
                    <span id="update-skip" class="update-notify-action">{{ _( "Do not remind me this version" ) }}</span>
                    <span id="update-message"></span>
                    <span> &nbsp; <a id="update-viewchanges" target="_blank">{{ _( "View changes" ) }}</a></span>
                </div> <!-- #update-notify -->
                <div id="update-progress-bar" class="popnotify fade in hide">
                    <span class=""></span>
                </div> <!-- #update-progress-bar -->
                <h2 id="title"></h2>
                <div id="tip" class="alert fade in hide">
                    <button id="tip-close" type="button" class="close">×</button>
                    <p id="tip-message" class="message"></p>
                </div> <!-- #tip -->
                %s
            </div>
        </div> <!-- .row-fluid -->
    </div> <!-- .container -->
</div> <!-- #content -->
<!-- JavaScript -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript">
    $(function () {
        window.isFullWidth = false;
        window.wiki_ISSUEID = 9696; //as default, an wiki/help issue, for failed-getting-releasenote-issue condition
        window.RELEASENOTE_ISSUEID = window.wiki_ISSUEID;
        window.welcomeISSUEID = window.wiki_ISSUEID;
    });
</script>
<script type="text/javascript">
    $('.fluid-down-control').click(function () {
        var isShown = $('i.icon', this).hasClass('icon-chevron-down');
        var id = $(this).attr('for');

        if (!isShown) {
            $('i.icon', this).removeClass('icon-chevron-right');
            $('i.icon', this).addClass('icon-chevron-down');
            $('#' + id).slideDown();
        } else {
            $('i.icon', this).removeClass('icon-chevron-down');
            $('i.icon', this).addClass('icon-chevron-right');
            $('#' + id).slideUp();
        }
    });
</script>
<script type="text/javascript">
    $('#resize-window-trigger').click(function () {
        isFullWidth = !isFullWidth;

        if (isFullWidth) {
            $('img', this).attr('src', '/img/full-width.png');
            $('.container').addClass('container-fluid');
            $('.container').removeClass('container');
        } else {
            $('img', this).attr('src', '/img/fixed-width.png');
            $('.container-fluid').addClass('container');
            $('.container-fluid').removeClass('container-fluid');
        }
    });

    $('#quit-trigger').click(function () {
        $.ajax({
            type: 'GET',
            url: '/quit',
            dataType: 'JSON',
            success: function (result) {
                if (result['status'] == 'success') {
                    tip('{{ _( "Exited successfully." ) }}', 'success');
                } else {
                    tip('{{ _( "Exitting failed." ) }}', 'error');
                }
            },
            error: function () {
                tip('{{ _( "Exitting failed. A network error occurred." ) }}', 'error');
            }
        });
    });

    $('#btn-learnmore').click(function () {
        popIssue(window.welcomeISSUEID);
        setTimeout(function () {
            $('#welcome').addClass('hide');
        }, 1000);
    });

    $('#notice').click(function () {
        if ($('#notice-content', this).html() == '') {
            getNotice();
        }
    });

    function welcomeClose() {
        $('#welcome').addClass('hide');
        setConfig('postUpdateStat', "noChange");
    }

    function updateWelcome() {
        switch (getConfig('postUpdateStat')) {
            case "noChange":
                $('#welcome').addClass('hide');
                break;
            case "isNew":
                $('#welcome-title').text('{{ _( "Hello!" ) }}');
                $('#welcome-message').text('{{ _( "You seem to be on your first visit." ) }}');
                window.welcomeISSUEID = window.wiki_ISSUEID;
                $('#welcome').removeClass('hide');
                setTimeout(welcomeClose(), 15 * 1000);
                break;
            case "isPostUpdate":
                $('#welcome-title').text('{{ _( "Hello!" ) }}');
                $('#welcome-message').text('{{ _( "new to this version?" ) }}');
                window.welcomeISSUEID = window.RELEASENOTE_ISSUEID;
                $('#welcome').removeClass('hide');
                setTimeout(welcomeClose(), 15 * 1000);
                break;
            default:
        }
    }

    function updateNotice(contents, appendMode) {
        //appendMode = appendMode || false;
        if (!contents || contents.length <= 0) return;

        var content = document.getElementById('notice-content');
        if (!appendMode) {
            content.innerHTML = '';
        }

        var i, limit = 30;
        var cur = content.firstChild;
        for (i = 0; i < limit && cur && contents.length > 0; i++) {
            var issue = contents[0];
            if (cur.id.substring(6) < issue[0]) {
                var li = document.createElement('li');
                li.setAttribute('id', "issue_" + issue[0]);
                var a = document.createElement('a');
                a.textContent = issue[1];
                a.href = issue[2];
                a.issueid = issue[0];
                a.onclick = function() {
                    popIssue(this.issueid);
                    return false;
                }
                li.appendChild(a);
                content.insertBefore(li, cur);
                contents.shift();
            } else if (cur.id.substring(6) == issue[0]) {
                cur = cur.nextSibling;
                contents.shift();
            } else if (cur.id.substring(6) > issue[0]) {
                cur = cur.nextSibling;
            } else {
                displayErrorMessage();
            }
        }
        if (contents.length > 0) {
            while (i < limit && contents.length > 0) {
                var issue = contents.shift();
                var li = document.createElement('li');
                li.setAttribute('id', "issue_" + issue[0]);
                var a = document.createElement('a');
                a.textContent = issue[1];
                a.href = issue[2];
                a.issueid = issue[0];
                a.onclick = function() {
                    popIssue(this.issueid);
                    return false;
                }
                li.appendChild(a);
                content.appendChild(li);
                i++;
            }
            return;
        }
        //if (cur && i >= limit) { //exceed limit, do nothing for now }
    }

    function getIssuesByLabels(labels, callback, repo) {
        repo = repo || "XX-net/XX-Net";
        //var APIurl = "https://api.github.com/repos/XX-net/XX-Net/issues?" + "no:label"; //for test, get all commits without label
        var APIurl = "https://api.github.com/repos/" + repo + "/issues?page=1&labels=" + labels; //console.log('APIurl='+APIurl);
        $.ajax({
            type: 'GET',
            url: APIurl,
            dataType: 'JSON',
            success: callback,
            error: function (result) {
                console.log("Failed loading issues of " + labels + ".");
            }
        });
    }

    function getNoticeCallback(result) {
        var t = [];
        for (var i = 0; i < result.length; i++) {
            var issue = result[i];
            t.push([issue.number, issue.title, issue.html_url]);
        }
        updateNotice(t, true);
    }

    function getNotice() {
        var pageRequests = {
            'cmd': 'get_version'
        };
        $.ajax({
            type: 'GET',
            url: '/config',
            data: pageRequests,
            dataType: 'JSON',
            success: function (result) {
                var currentVerBig = result['current_version'].replace(/(\d+)$/, "x");
                var currentVerBigSplit = currentVerBig.split('.');
                currentVerBigSplit[1] = parseInt(currentVerBigSplit[1]) + 1;
                var currentVerNextBig = currentVerBigSplit.join('.');
                getIssuesByLabels("公告", getNoticeCallback);
                getIssuesByLabels(currentVerBig, getNoticeCallback);
                getIssuesByLabels(currentVerNextBig, getNoticeCallback);
            }
        });
    }

    function getRELEASENOTE_ISSUEID_Callback(result) {
        if (result.length === 0) {
            console.log("NO RELEASENOTE_ISSUEID related to '" + currentVer + "'.");
            return;
        }
        var issueURL = result[0]['url'].split('/');
        window.RELEASENOTE_ISSUEID = issueURL[7];
    }

    function getRELEASENOTE_ISSUEID(version) {
        var versionSplit = version.split('.');
        versionSplit[2] = 'x';
        var versionSplitBig = versionSplit.join('.');
        getIssuesByLabels("发布," + versionSplitBig, getRELEASENOTE_ISSUEID_Callback);
        updateWelcome();
    }
</script>
<script type="text/javascript">
    function getConfig(key) {
        var result;
        var pageRequests = {
            'cmd': 'get_config'
        };
        $.ajax({
            async: false,
            type: 'GET',
            url: '/config',
            data: pageRequests,
            dataType: 'JSON',
            success: function (res) {
                result = res;
            },
            error: function (res) {
                result = res;
            }
        });
        if (key) {
            var res = result;
            result = "nomatch";
            Object.keys(res).forEach(function (t) {
                if (t === key) {
                    result = res[t];
                    //return;
                }
            });
        }
        return result;
    }

    function setConfig(key, value) {
        //var result;
        var pageRequests = {
            'cmd': 'set_config'
        };
        pageRequests[key] = value;
        $.ajax({
            //async: false,
            type: 'GET',
            url: '/config',
            data: pageRequests,
            dataType: 'JSON',
            success: function (result) {
                if (result && (result['res'] === 'success')) {
                    if (key === 'postUpdateStat') return;
                    tip('{{ _( "Settings saved successfully." ) }}', 'success');
                    if (key === 'gae_proxy_enable' || key === 'x_tunnel_enable' || key === 'smart_router_enable') {
                        restartingService(key); //call from config.html
                    }
                } else {
                    displayErrorMessage();
                }
            },
            error: function (result) {
                displayErrorMessage();
            }
        });
        //return result;
    }

    function displayErrorMessage() {
        tip('{{ _( "Unkown error occured. Please refresh the page and try again." ) }}', 'error');
    }
</script>
<script type="text/javascript">
    init_main();
    function init_main() {
        var pageRequests = {
            'cmd': 'get_version'
        };
        $.ajax({
            type: 'GET',
            url: '/config',
            data: pageRequests,
            dataType: 'JSON',
            success: function (result) {
                var currentVer = result['current_version'];
                document.getElementById("version_on_logo").appendChild(document.createTextNode(currentVer));

                getRELEASENOTE_ISSUEID(currentVer);
            }
        });

        if (getConfig('allow_remote_connect') !== 0) {
            $('#remote-connection-identifier').show();
        }
    }
</script>
<script type="text/javascript">
    var checkUpdateTimeout = 600000;
    var checkUpdateTimer;
    var versionToUpdate;
    var versionType;

    function startUpdateCheck() {
        $('#update-notify').addClass('hide');

        var pageRequests = {
            'cmd': 'start_check',
            'check_update': $('#check-update').val()//getConfig('check-update')
        };
        $.ajax({
            type: 'GET',
            url: '/update',
            data: pageRequests,
            dataType: 'JSON',
            success: function (result) {
                if (result['res'] === 'success') {
                    getUpdateInfo();
                    checkUpdateTimer.play();
                } else {
                    tip(result['reason'], "warning");
                }
            },
            error: function () {
                displayErrorMessage();
            }
        });
    }

    function stopUpdateCheck() {
        $('#update-notify').addClass('hide');
        checkUpdateTimer.stop();

        var pageRequests = {
            'cmd': 'set_info',
            'info': 'dont-check'
        };
        $.ajax({
            type: 'GET',
            url: '/update',
            data: pageRequests,
            dataType: 'JSON',
            success: function (result) {
                if (result['res'] !== 'success') {
                    tip(result['reason'], 'warning');
                }
            },
            error: function () {
                displayErrorMessage();
            }
        });
    }

    function clearUpdateInfo() {
        $('#update-notify').addClass('hide');

        var pageRequests = {
            'cmd': 'set_info',
            'info': ''
        };
        $.ajax({
            type: 'GET',
            url: '/update',
            data: pageRequests,
            dataType: 'JSON',
            success: function (result) {
                if (result['res'] !== 'success') {
                    tip(result['reason'], "warning");
                }
            },
            error: function () {
                displayErrorMessage();
            }
        });
    }

    function skipUpdateVersion() {
        $('#update-notify').addClass('hide');
        checkUpdateTimer.stop();

        var pageRequests = {
            'cmd': 'set_config',
            'skip_version': versionToUpdate,
            'skip_version_type': versionType
        };
        $.ajax({
            type: 'GET',
            url: '/config',
            data: pageRequests,
            dataType: 'JSON',
            success: function (result) {
                if (result['res'] !== 'success') {
                    tip(result['reason'], "warning");
                }
            },
            error: function () {
                displayErrorMessage();
            }
        });
    }

    function updateBase(checkhash) {
        $('#update-notify').addClass('hide');

        var pageRequests = {
            'cmd': 'update_version',
            'version': versionToUpdate,
            'checkhash': checkhash || 0
        };
        versionToUpdate = null;
        $.ajax({
            type: 'GET',
            url: '/update',
            data: pageRequests,
            dataType: 'JSON',
            success: function (result) {
                if (result['res'] === 'success') {
                    tip('{{ _( "Updating in progress ..." ) }}', "info");
                    window.updateProgress_timer.play();
                } else {
                    tip(result['reason'], "warning");
                }
            },
            error: function () {
                displayErrorMessage();
            }
        });
    }
    function updateVersion() {
        updateBase(1);
    }
    function updateVersionWithoutHashCheck() {
        updateBase(0);
    }

    function getUpdateInfo() {
        if (!$('#update-notify').hasClass('hide') ||
            !$('#update-progress-bar').hasClass('hide')) {
            return;
        }

        var pageRequests = {
            'cmd': 'get_info'
        };
        $.ajax({
            type: 'GET',
            url: '/update',
            data: pageRequests,
            dataType: 'JSON',
            success: function (result) {
                versionType = result['type'];
                switch (versionType) {
                    case 'init':
                        window.setTimeout(startUpdateCheck, 1000);
                        break;
                    case 'dont-check':
                        //stopUpdateCheck();
                        $('#update-notify').addClass('hide');
                        checkUpdateTimer.stop();
                        break;
                    default:
                        versionToUpdate = result['version'];
                        if (versionType && versionToUpdate) {
                            switch (versionType) {
                                case 'stable':
                                    var popText = '{{ _( "New " ) }}{{ _( "Stable version" ) }} ' + versionToUpdate;
                                    break;
                                case 'test':
                                    var popText = '{{ _( "New " ) }}{{ _( "Test version" ) }} ' + versionToUpdate;
                            }
                            $('#update-message').text(popText);
                            $('#update-viewchanges').attr("href", "https://github.com/XX-net/XX-Net/releases/tag/" + versionToUpdate);
                            $('#update-notify').removeClass('hide');
                        }
                }
            }
        });
    }

    function updateProgress() { //TODO: 完善tip（详细信息、翻译, etc.)
        $.getJSON('update?cmd=get_progress', function (result) {
            Object.keys(result).forEach(function (v) {
                if (v === "update_status") {
                    var stat = result[v];
                    switch (stat) {
                        case "Idle":
                            window.updateProgress_timer.stop();
                            break;
                        case "Finished":
                            tip('{{ _( "Finished." ) }}', 'info');
                            window.loading.stop();
                            window.updateProgress_timer.stop();
                            break;
                        default:
                            if (stat.indexOf('Fail') > -1) {
                                tip(stat, 'warning');
                                window.updateProgress_timer.stop();
                            } else {
                                tip(stat, 'info');
                            }
                    }
                    /*
                    if (stat === "Idle") {
                        window.updateProgress_timer.stop();
                        return;
                    }
                    /*
                    if ($('#upgrade-pull-icon').hasClass('icon-chevron-right')) {
                        var current_version = $('#current-version-no').html();
                        if (current_version === "") {
                            $('#current-version-no').html(" "); // avoid check next time.
                            check_new_version();
                        }

                        $('.version-line').slideDown('fast');

                        $('#upgrade-pull-icon').removeClass('icon-chevron-right');
                        $('#upgrade-pull-icon').addClass('icon-chevron-down');
                        $('#update-options').slideDown();
                    }

                    if (stat === "Finished") {
                        tip(stat, 'info');
                        window.loading.stop();
                        window.updateProgress_timer.stop();
                        //return;
                    } else if (stat.indexOf('Fail') > -1) {
                        tip(stat, 'warning');
                        window.updateProgress_timer.stop();
                    } else {
                        tip(stat, 'info');
                    }
                    */
                } else if (v.indexOf('XX-Net/zip') > -1) {
                    if (!window.updating_button) {
                        var p = v.indexOf('XX-Net/zip') + 11;
                        var version = v.substring(p, v.length);
                        var button;
                        if (version === $('#test-version-no').html()) {
                            button = $('#update-test-version');
                        } else if (version === $('#stable-version-no').html()) {
                            button = $('#update-stable-version');
                        } else if ($('.active a').attr('href') === '/?module=launcher&menu=config') {
                            return;
                        } else {
                            button = $('#update-progress-bar').find('span');
                            $('#update-progress-bar').removeClass('hide');
                        }
                        window.updating_button = button;
                    }
                    $('#update-notify').addClass('hide');

                    if (!window.loading) {
                        window.loading = Ladda.create(window.updating_button[0]);
                        window.loading.start();
                    }
                    var data = result[v];
                    if (data.status === 'downloading') {
                        var progress = (+data.downloaded / +data.size) * 100;
                        window.loading.setProgress(progress);
                        window.updating_button.html('{{ _( "Downloading ..." ) }}' + parseInt(progress) + '&#37;');
                    } else if (data.status === "finished") {
                        window.updating_button.html('{{ _( "Download completed." ) }}');
                        window.updating_button.prop('disabled', true);
                        window.updating_button = null;
                        window.setTimeout(function clearProgressBar() {
                            $('#update-progress-bar').addClass('hide');
                        }, 5000);
                        window.loading.stop();
                        window.updateProgress_timer.stop();
                    }
                }
            });
        });
    }

    $(document).ready(function () {
        var rfn;
        for (rfn in documentReadyToRun) {
            documentReadyToRun[rfn]();
        }
        window.updateProgress_timer = $.timer(updateProgress, 1000, true);
        updateProgress();
        checkUpdateTimer = $.timer(getUpdateInfo, checkUpdateTimeout, true);
        window.setTimeout(getUpdateInfo, 1000);
    });

    $('#update-now').click(updateVersion);
    $('#update-next').click(clearUpdateInfo);
    $('#update-skip').click(skipUpdateVersion);
    $('#update-notify-close').click(clearUpdateInfo);
    // site.js fix
    $('#tip-close').click(tipClose);
</script>
<div id="display-issue-modal" class="modal hide fade" style="width: auto;">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3 id="display-issue-model-title">{{ _( "Info" ) }}</h3>
    </div> <!-- .modal-header -->
    <div id="display-issue-modal-body" class="modal-body">
    </div> <!-- .modal-body -->
    <div class="modal-footer">
    </div> <!-- .modal-footer -->
</div> <!-- #display-issue-modal -->
<link rel="stylesheet" type="text/css" href="/css/primer-markdown.css">
<script type="text/javascript">
    function renderMD(rawText, mode, context) {
        if (rawText === undefined) {
            throw new Error("rawText undefined");
        }
        var res = document.createElement('div');
        res.setAttribute('class', 'markdown-body');
        var rq = {
            'text': rawText,
            'mode': mode || 'gfm',
            'context': context || 'XX-net/XX-Net'
        };
        $.ajax({
            async: false,
            type: 'POST',
            url: 'https://api.github.com/markdown',
            data: JSON.stringify(rq),
            contentType: 'application/json',
            dataType: 'html',// Accept: application/vnd.github.v3.html+json
            // timeout: 1000,
            success: function (result) {
                res.innerHTML = result;
            },
            error: function (result) {
                throw new Error("Failed rendering.");
            }
        });
        return res;
    }

    function popIssue(issueID, repo) {
        repo = repo || 'XX-net/XX-Net';
        issueID = issueID || window.RELEASENOTE_ISSUEID;
        try {
            var APIurl = 'https://api.github.com/repos/' + repo + '/issues/' + issueID;
            $.ajax({
                //async: false,
                type: 'GET',
                url: APIurl,
                dataType: 'JSON',
                success: function (result) {
                    var title = document.getElementById('display-issue-model-title');
                    title.innerHTML = '<a href="' + result['html_url'] + '" target="_blank" style="color: grey">' + result['title'] + '</a>';
                    var rawText = result['body'];
                    var rendered;
                    try {
                        rendered = renderMD(rawText);
                    }
                    catch (err) {
                        throw err;
                    }
                    var body = document.getElementById('display-issue-modal-body');
                    body.innerHTML = rendered.outerHTML;
                    // body.style('https://unpkg.com/primer-markdown/build/build.css');
                    $('#display-issue-modal').modal();
                },
                error: function (result) {
                    throw new Error("Failed loading.");
                }
            });
        }
        catch (err) {
            // console.log(err.message);
            // tip('{ { _( err ) }}', 'error');
        }
    }
</script>
</body>
</html>
